/*
 * Copyright 2010 Christoph Widulle (christoph.widulle@googlemail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */



package com.android1.amarena2d.actions.movement;

import com.android1.amarena2d.actions.base.InfiniteTimeAction;
import com.android1.amarena2d.nodes.behavior.ActionTarget;

public class Move extends InfiniteTimeAction {

    float velocityX;
    float velocityY;

    public Move(float velocityX, float velocityY) {
        this.velocityX = velocityX;
        this.velocityY = velocityY;
    }

    public static Move $(float velocityX, float velocityY) {
        return new Move(velocityX, velocityY);
    }

    public void reset(float velocityX, float velocityY) {
        this.velocityX = velocityX;
        this.velocityY = velocityY;
    }

    @Override
    public void start(ActionTarget target) {
        super.start(target);
    }

    @Override
    public void tick(float delta) {
        target.addXY(velocityX * delta, velocityY * delta);
    }

    public Move reverse() {
        return Move.$(-velocityX, -velocityY);
    }

    @Override
    public Move copy() {
        return Move.$(velocityX, velocityY);
    }

    public float getVelocityX() {
        return velocityX;
    }

    public void setVelocityX(float velocityX) {
        this.velocityX = velocityX;
    }

    public float getVelocityY() {
        return velocityY;
    }

    public void setVelocityY(float velocityY) {
        this.velocityY = velocityY;
    }
}